Release 10.1A: OpenEdge Development:
Messaging and ESB


Client persistence

Client persistence allows the JMS session to continue sending messages regardless of the SonicMQ Broker status. If the SonicMQ Broker is not available, the messages are stored locally and sent when the SonicMQ Broker becomes available.

For more information on client persistence, see the "Client persistence" section.

The following code sample shows how to set up client persistence:

Client persistence example
DEFINE VARIABLE sessionH AS HANDLE. 
DEFINE VARIABLE rejectedMsgH AS HANDLE. 
/* Run adapter as symbiotic process */ 
RUN jms/jmssession.p PERSISTENT SET sessionH ("-SMQConnect"). 
/* Set local store directory off of current working directory */ 
RUN setLocalStoreDirectory IN sessionH ("mqstore"). 
RUN setLocalStoreSize IN sessionH (5000). 
/* Set timeouts - Retry every 5 minutes and give up if broker down 10 hours */ 
RUN setReconnectTimeout IN sessionH (600). 
RUN setReconnectInterval IN sessionH (300). 
RUN setClientPersistence IN sessionH (TRUE). 
RUN setBrokerURL IN sessionH ("MQBrokerHost:2506"). 
RUN setClientID IN sessionH ("SomeUniqueName"). 
RUN beginSession IN sessionH. 
/* Once session is established, create rejected Message Consumer */ 
RUN createRejectedMessageConsumer  
    IN sessionH (THIS-PROCEDURE, "RejectedMsgHandler", OUTPUT rejectedMsgH). 
PROCEDURE RejectedMsgHandler: 
DEFINE INPUT PARAMETER messageH AS HANDLE NO-UNDO. 
DEFINE INPUT PARAMETER messageConsumerH AS HANDLE NO-UNDO. 
DEFINE OUTPUT PARAMETER autoReplyH AS HANDLE NO-UNDO. /* Not used in example */ 
DEFINE VARIABLE numParts AS INTEGER NO-UNDO. 
DEFINE VARIABLE contentType AS CHARACTER NO-UNDO. 
DEFINE VARIABLE errorCode AS CHARACTER NO-UNDO. 
DEFINE VARIABLE exceptionCode AS CHARACTER NO-UNDO. 
DEFINE VARIABLE errorText AS CHARACTER NO-UNDO. 
DEFINE VARIABLE msgType AS CHARACTER NO-UNDO. 
DEFINE VARIABLE messagePartH AS HANDLE NO-UNDO. 
MESSAGE "Reject message" VIEW-AS alert-box. 
errorCode = DYNAMIC-FUNCTION("getCharProperty" IN messageH, "errorCode"). 
errorText = DYNAMIC-FUNCTION("getCharProperty" IN messageH, "errorText"). 
exceptionCode = DYNAMIC-FUNCTION("getCharProperty" IN messageH, "exception"). 
MESSAGE errorText VIEW-AS ALERT-BOX. 
DISPLAY errorCode exceptionCode. 
numParts = DYNAMIC-FUNCTION("getPartCount" IN messageH). 
IF DYNAMIC-FUNCTION("isMessagePart" IN messageH, 1) = TRUE THEN DO: 
  contentType = DYNAMIC-FUNCTION("getMessagePartByIndex":U IN messageH, 
                                 INPUT numParts, 
                                 OUTPUT messagePartH). 
  msgType = DYNAMIC-FUNCTION('getMessageType':U IN messagePartH). 
  DISPLAY numParts msgType contentType. 
END. 
RUN deleteMessage IN messageH. 
END. 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095